﻿using Share.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace Share.APIs;

public class QHisBal : IcbcApiRequest
{
    internal override string Url => "api/mybank/enterprise/account/meahisbalqry/V1";

    [JsonPropertyName("trans_code")] public string TransCode => "QHISBAL";
    [JsonPropertyName("tran_date")] public string TranDate { get; set; } = DateTime.Today.ToString("yyyyMMdd");
    [JsonPropertyName("tran_time")] public string TranTime { get; set; } = DateTime.Now.ToString("HHmmssfff");
    [JsonPropertyName("language")] public string? Language { get; set; } = "zh_cn";
    [JsonPropertyName("f_seq_no")] public string FSeqNo { get; set; } = UtilitiesService.GetFSeqNo();
    [JsonPropertyName("account_no")] public string AccountNo { get; set; } = string.Empty;
    [JsonPropertyName("currency")] public string? Currency { get; set; } = string.Empty;
    [JsonPropertyName("begin_date")] public string BeginDate { get; set; } = string.Empty;
    [JsonPropertyName("end_date")] public string EndDate { get; set; } = string.Empty;
    [JsonPropertyName("acct_seq")] public string? AcctSeq { get; set; } = string.Empty;
    [JsonPropertyName("open_bankbic")] public string? OpenBankbic { get; set; } = string.Empty;
    [JsonPropertyName("open_bank_no")] public string? OpenBankNo { get; set; } = string.Empty;
}

public class QHisBalResponse:IcbcApiResponse
{    
    [JsonPropertyName("account_no")] public string? AccountNo { get; set; } = string.Empty;
    [JsonPropertyName("account_name")] public string? AccountName { get; set; } = string.Empty;
    [JsonPropertyName("currency")] public string? Currency { get; set; } = string.Empty;
    [JsonPropertyName("account_property")] public string? AccountProperty { get; set; } = string.Empty;
    [JsonPropertyName("begin_date")] public string? BeginDate { get; set; } = string.Empty;
    [JsonPropertyName("end_date")] public string? EndDate { get; set; } = string.Empty;
    [JsonPropertyName("acct_seq")] public string? AcctSeq { get; set; } = string.Empty;
    [JsonPropertyName("rd")] public List<QHisBalResponseRd> Rd { get; set; } = [];
}

public class QHisBalResponseRd
{
    [JsonPropertyName("date")] public string? Date { get; set; } = string.Empty;
    [JsonPropertyName("amount")] public decimal Amount { get; set; }
    [JsonPropertyName("pool_amt")] public decimal PoolAmt { get; set; }

}